package com.freda.oa.flow.run.model.impl;

import com.freda.oa.flow.run.model.itf.FlowTaskModelItf;
import com.freda.oa.flow.run.vo.FlowRunInfoVo;
import com.freda.oa.flow.utl.FlowIdHelper;

/**
 * 操作task
 * @author Rally
 *
 */
public class FlowTaskModelImpl extends FlowBaseModelImpl implements FlowTaskModelItf{
	
	/* (non-Javadoc)
	 * @see com.freda.oa.flow.run.model.impl.FlowTaskModelItf#addTask(com.freda.oa.flow.run.vo.FlowRunInfoVo)
	 */
	@Override
	public int addTask(FlowRunInfoVo runInfo)
	{
		
		String taskId = FlowIdHelper.getTaskId();
		
		runInfo.setTaskId(taskId);
		
		g4Dao.insert("FlowTask.add", runInfo);
		
		return 1;
	}
	
	/* (non-Javadoc)
	 * @see com.freda.oa.flow.run.model.impl.FlowTaskModelItf#lockAssignee(com.freda.oa.flow.run.vo.FlowRunInfoVo)
	 */
	@Override
	public int lockAssignee(FlowRunInfoVo runInfo)
	{
		if(g4Dao.update("FlowTask.lockAssignee", runInfo) == 1)
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	
	/* (non-Javadoc)
	 * @see com.freda.oa.flow.run.model.impl.FlowTaskModelItf#unLockAssignee(com.freda.oa.flow.run.vo.FlowRunInfoVo)
	 */
	@Override
	public int unLockAssignee(FlowRunInfoVo runInfo)
	{
		if(g4Dao.update("FlowTask.unLockAssignee", runInfo) != 1)
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	
	/* (non-Javadoc)
	 * @see com.freda.oa.flow.run.model.impl.FlowTaskModelItf#delTask(com.freda.oa.flow.run.vo.FlowRunInfoVo)
	 */
	@Override
	public int delTask(FlowRunInfoVo runInfo)
	{
		if(g4Dao.delete("FlowTask.del", runInfo) != -1)
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	
	/* (non-Javadoc)
	 * @see com.freda.oa.flow.run.model.impl.FlowTaskModelItf#editTask(com.freda.oa.flow.run.vo.FlowRunInfoVo)
	 */
	@Override
	public int editTask(FlowRunInfoVo runInfo)
	{
		if(g4Dao.update("FlowTask.update", runInfo) != -1)
		{
			return 1;
		}
		else
		{
			return 0;			
		}
	}

}
